<div id="members">
<div class="row">
    <div class="col">
    <?php echo CHtml::activeLabelEx($member,"[$belong]type"); ?>
    <?php echo CHtml::activeDropDownList($member,"[$belong]type",company_members::model()->memberType); ?>
    </div>
</div>
<div class="row">
    <div class="col">
    <?php echo CHtml::activeLabelEx($member,"[$belong]name"); ?>
    <?php echo CHtml::activeTextField($member, "[$belong]name",array('size'=>40)); ?>
    </div>
</div>
<div id="contacts">
<div class="row">
    <div class="col"><?php echo CHtml::label("Contacts", 'contact');?></div>
    <div class="col" id="telephone">
        <?php foreach($member->contacts as $i=>$item): if($item['type']>0 && $item['type']<10):?>
        <div>
            <?php echo CHtml::activeDropDownList($item, "[$belong]type", company_members_contacts::model()->teleType,array('name'=>"company_members_contacts[$belong][$i][type]")); ?>
            <?php echo CHtml::activeTextField($item,"[$belong]ref",array('size'=>25,'maxlength'=>35,'name'=>"company_members_contacts[$belong][$i][ref]")); ?>
        </div>
        <?php endif; endforeach; ?>
    </div>
</div>
</div>
    <div id="email">
<div class="row">
    <div class="col"><?php echo CHtml::label("Email", 'email');?></div>
    <div class="col" id="email">
    <?php foreach($member->email as $i=>$item):?>
        <div>
            <?php echo CHtml::activeDropDownList($item, "[$belong]type[$i]",company_members_email::model()->emailType,array('name'=>"company_members_email[$belong][$i][type]")); ?>
            <?php echo CHtml::activeTextField($item,"[$belong]ref[$i]",array('size'=>35,'maxlength'=>254,'name'=>"company_members_email[$belong][$i][ref]")); ?>
        </div>
    <?php endforeach; ?></div>
</div>
</div>
</div>
<?php
    $cs = Yii::app()->getClientScript();
    $contact = count($member->contacts)-1;
    $email = count($member->email)-1;
    $s =<<<EOD
        $('div#tabmember').data('index',$belong);
        $('#tabmember').children('div').eq($belong).children('div#contacts').data('index',$contact);
        $('#tabmember').children('div').eq($belong).children('div#email').data('index',$email);
EOD;
    $cs->registerScript('memberIndex#'.$belong,$s);
?>